package com.snopy.concurrency.demo_threadpool;

import com.snopy.concurrency.threadFactory.CustomThreadFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author snopy
 * @version 1.0.0
 * @classname NewSingleThreadPoolTest
 * @description
 * @email 77912204@qq.com
 * @date 2022/02/19 19:03
 */
@Slf4j
public class NewSingleThreadPoolTest {
    static final ExecutorService es = Executors.newSingleThreadExecutor();
    static final ExecutorService es2 = Executors.newSingleThreadExecutor(new CustomThreadFactory("自定义测试"));
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            es.submit(new Runnable() {
                @Override
                public void run() {
                    log.info("当前线程->{}",Thread.currentThread().getName());
                }
            });
            es2.submit(new Runnable() {
                @Override
                public void run() {
                    log.info("当前线程2->{}",Thread.currentThread().getName());
                }
            });
        }
    }
}
